﻿using Game3D;

namespace GameLogic
{
    class LogicBlock
    {
        /// <summary>
        /// The shape of the LogicBlock (to determine the position and collisions)
        /// </summary>
        public Shape Type
        {
            get;
            set;
        }

        /// <summary>
        /// The former shape of the LogicBlock. When it will be set to static, the current type will be set Shape.Single. Helps to save the color.
        /// </summary>
        public Shape OldType { get; private set; }

        /// <summary>
        /// Every Block in the game has its own ID. With this the Block can be identified through the game and its lifetime. 
        /// </summary>
        public int ID { get; set; }
        /// <summary>
        /// The rotation helps to calculate collisions
        /// </summary>
        public int Rotation { get; set; }
        /// <summary>
        /// Converts a dynamic LogicBlock into a static logic block. That helps to remove them easily.
        /// </summary>
        public bool Static {
            get
            {
                return Type == Shape.Single ? true : false;
            }
            set
            {
                if (value == true)
                {
                    OldType = Type;
                    Type = Shape.Single;
                }
            }
        }

        /// <summary>
        /// Creates a simple LogicBlock with default values.
        /// </summary>
        public LogicBlock()
        {
            ID = 0;
            Type = Shape.Single;
            Rotation = 0;
            Static = false;
        }

        /// <summary>
        /// Creates a LogicBlock with given values.
        /// </summary>
        /// <param name="ID">Sets the unique ID in the game.</param>
        /// <param name="Type">Sets the type of the LogicBlock.</param>
        public LogicBlock(int ID, Shape Type) : this()
        {
            this.ID = ID;
            this.Type = Type;
        }

        /// <summary>
        /// Creates a LogicBlock with given values.
        /// </summary>
        /// <param name="ID">Sets the unique ID in the game.</param>
        /// <param name="Type">Sets the type of the LogicBlock.</param>
        /// <param name="Rotation">Sets the initial rotation of the LogicBlock.</param>
        public LogicBlock(int ID, Shape Type, int Rotation) : this(ID, Type)
        {
            this.Rotation = Rotation;
        }
    }
}
